﻿@model OrderModel

@using SDF.Core.Domain.Tax;
@using SDF.Core.Domain.Orders;
@using SDF.Services

@if (!Model.IsLoggedInAsVendor)
{
    <script type="text/javascript">
        $(document).ready(function () {
            toggleChangeOrderStatus(false);
            toggleOrderTotals(false);
            toggleCC(false);
        });

        function toggleChangeOrderStatus(editmode) {
            if (editmode) {
                $('#pnlChangeOrderStatus').show();
                $('#btnChangeOrderStatus').hide();
            } else {
                $('#pnlChangeOrderStatus').hide();
                $('#btnChangeOrderStatus').show();
            }
        }

        function toggleOrderTotals(editmode) {
            if (editmode) {
                $('#trEditOrderTotals').show();
                $('#btnEditOrderTotals').hide();
                $('#btnSaveOrderTotals').show();
                $('#btnCancelOrderTotals').show();
            } else {
                $('#trEditOrderTotals').hide();
                $('#btnEditOrderTotals').show();
                $('#btnSaveOrderTotals').hide();
                $('#btnCancelOrderTotals').hide();
            }
        }

        function toggleCC(editmode) {
            if (editmode) {
                $('#lblCardType').hide();
                $('#@Html.FieldIdFor(model => model.CardType)').show();
                $('#lblCardName').hide();
                $('#@Html.FieldIdFor(model => model.CardName)').show();
                $('#lblCardNumber').hide();
                $('#@Html.FieldIdFor(model => model.CardNumber)').show();
                $('#lblCardCvv2').hide();
                $('#@Html.FieldIdFor(model => model.CardCvv2)').show();
                $('#lblCardExpirationMonth').hide();
                $('#@Html.FieldIdFor(model => model.CardExpirationMonth)').show();
                $('#lblCardExpirationYear').hide();
                $('#@Html.FieldIdFor(model => model.CardExpirationYear)').show();
                $('#btnEditCC').hide();
                $('#btnSaveCC').show();
                $('#btnCancelCC').show();
            } else {
                $('#lblCardType').show();
                $('#@Html.FieldIdFor(model => model.CardType)').hide();
                $('#lblCardName').show();
                $('#@Html.FieldIdFor(model => model.CardName)').hide();
                $('#lblCardNumber').show();
                $('#@Html.FieldIdFor(model => model.CardNumber)').hide();
                $('#lblCardCvv2').show();
                $('#@Html.FieldIdFor(model => model.CardCvv2)').hide();
                $('#lblCardExpirationMonth').show();
                $('#@Html.FieldIdFor(model => model.CardExpirationMonth)').hide();
                $('#lblCardExpirationYear').show();
                $('#@Html.FieldIdFor(model => model.CardExpirationYear)').hide();
                $('#btnEditCC').show();
                $('#btnSaveCC').hide();
                $('#btnCancelCC').hide();
            }
        }
    </script>
}

<div class="panel-group">
    <div class="panel panel-default">
        <div class="panel-body">
            @if (!Model.IsLoggedInAsVendor)
            {
                <div class="form-group">
                    <div class="col-md-3">
                        @Html.SDFLabelFor(model => model.OrderStatus)
                    </div>
                    <div class="col-md-9">
                        <div class="input-group input-group-short">
                            <div class="input-group-text">
                                <strong>
                                    @Html.SDFDisplayFor(model => model.OrderStatus)
                                </strong>
                            </div>
                            <div class="input-group-btn">
                                @if (Model.CanCancelOrder)
                                {
                                    <button type="submit" name="cancelorder" id="cancelorder" class="btn bg-red" style="margin-right: 3px;">
                                        @T("Admin.Orders.Fields.OrderStatus.Cancel")
                                    </button>
                                    @Html.ActionConfirmation("cancelorder")
                                }
                                <button type="submit" name="btnChangeOrderStatus" onclick="toggleChangeOrderStatus(true);return false;" id="btnChangeOrderStatus" class="btn btn-primary">
                                    @T("Admin.Orders.Fields.OrderStatus.Change")
                                </button>
                                <div id="pnlChangeOrderStatus" style="margin-top: 3px;">
                                    <div>
                                        <em>@T("Admin.Orders.Fields.OrderStatus.Change.ForAdvancedUsers")</em>
                                    </div>
                                    @Html.SDFDropDownListFor(model => model.OrderStatusId, ((OrderStatus)Model.OrderStatusId).ToSelectList())
                                    <button type="submit" name="btnSaveOrderStatus" id="btnSaveOrderStatus" class="btn btn-primary" style="margin-left: 3px">
                                        @T("Admin.Common.Save")
                                    </button>
                                    @Html.ActionConfirmation("btnSaveOrderStatus")

                                    <button type="submit" name="btnCancelOrderStatus" onclick="toggleChangeOrderStatus(false);return false;" id="btnCancelOrderStatus" class="btn bg-teal" style="margin-left: 3px">
                                        @T("Admin.Common.Cancel")
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            }
            <div class="form-group">
                <div class="col-md-3">
                    @Html.SDFLabelFor(model => model.Id)
                </div>
                <div class="col-md-9">
                    @Html.SDFDisplayFor(model => model.Id)
                </div>
            </div>
            @if (!Model.IsLoggedInAsVendor)
            {
                <div class="form-group">
                    <div class="col-md-3">
                        @Html.SDFLabelFor(model => model.OrderGuid)
                    </div>
                    <div class="col-md-9">
                        @Html.SDFDisplayFor(model => model.OrderGuid)
                    </div>
                </div>
            }
            <div class="form-group">
                <div class="col-md-3">
                    @Html.SDFLabelFor(model => model.ProjectName)
                </div>
                <div class="col-md-9">
                    @Html.SDFDisplayFor(model => model.ProjectName)
                </div>
            </div>
        </div>
    </div>

    <div class="panel panel-default">
        <div class="panel-body">
            @if (!Model.IsLoggedInAsVendor)
            {
                <div class="form-group">
                    <div class="col-md-3">
                        @Html.SDFLabelFor(model => model.CustomerId)
                    </div>
                    <div class="col-md-9">
                        @Html.ActionLink(Model.CustomerInfo, "Edit", "Customer", new { id = Model.CustomerId }, new { })
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-md-3">
                        @Html.SDFLabelFor(model => model.CustomerIp)
                    </div>
                    <div class="col-md-9">
                        @Html.SDFDisplayFor(model => model.CustomerIp)
                    </div>
                </div>
                if (Model.RecurringPaymentId > 0)
                {
                    <div class="form-group">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.RecurringPaymentId)
                        </div>
                        <div class="col-md-9">
                            <a href="@Url.Action("Edit", "RecurringPayment", new {id = Model.RecurringPaymentId})">@T("Admin.Common.View")</a>
                        </div>
                    </div>
                }
                if (!String.IsNullOrEmpty(Model.VatNumber))
                {
                    <div class="form-group">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.VatNumber)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFDisplayFor(model => model.VatNumber)
                        </div>
                    </div>
                }
                if (Model.AffiliateId > 0)
                {
                    <div class="form-group">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.AffiliateId)
                        </div>
                        <div class="col-md-9">
                            <a href="@Url.Action("Edit", "Affiliate", new {id = Model.AffiliateId})">@Model.AffiliateName - @T("Admin.Common.View")</a>
                        </div>
                    </div>
                }

                <div class="form-group">
                    <div class="col-md-3">
                        <div class="label-wrapper">
                            <label class="control-label">@T("Admin.Orders.Fields.OrderSubtotal")</label>
                            <div class="ico-help" title="@T("Admin.Orders.Fields.OrderSubtotal.Hint")">
                                <i class="fa fa-question-circle"></i>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-7">
                        <div class="row">
                            @if (Model.AllowCustomersToSelectTaxDisplayType || Model.TaxDisplayType == TaxDisplayType.IncludingTax)
                            {
                                <div class="col-md-2">
                                    <div class="form-text-row">
                                        @Html.DisplayFor(model => model.OrderSubtotalInclTax) <strong>@T("Admin.Orders.Fields.OrderSubtotalInclTax")</strong>
                                    </div>
                                </div>
                            }
                            @if (Model.AllowCustomersToSelectTaxDisplayType || Model.TaxDisplayType == TaxDisplayType.ExcludingTax)
                            {
                                <div class="col-md-10">
                                    <div class="form-text-row">
                                        @Html.DisplayFor(model => model.OrderSubtotalExclTax) <strong>@T("Admin.Orders.Fields.OrderSubtotalExclTax")</strong>
                                    </div>
                                </div>
                            }
                        </div>
                    </div>
                </div>
                if (((Model.AllowCustomersToSelectTaxDisplayType || Model.TaxDisplayType == TaxDisplayType.IncludingTax) && !String.IsNullOrEmpty(Model.OrderSubTotalDiscountInclTax)) ||
                    ((Model.AllowCustomersToSelectTaxDisplayType || Model.TaxDisplayType == TaxDisplayType.ExcludingTax) && !String.IsNullOrEmpty(Model.OrderSubTotalDiscountExclTax)))
                {
                    <div class="form-group">
                        <div class="col-md-3">
                            <div class="label-wrapper">
                                <label class="control-label">@T("Admin.Orders.Fields.OrderSubTotalDiscount")</label>
                                <div class="ico-help" title="@T("Admin.Orders.Fields.OrderSubTotalDiscount.Hint")">
                                    <i class="fa fa-question-circle"></i>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-7">
                            <div class="row">
                                @if ((Model.AllowCustomersToSelectTaxDisplayType || Model.TaxDisplayType == TaxDisplayType.IncludingTax) && !String.IsNullOrEmpty(Model.OrderSubTotalDiscountInclTax))
                                {
                                    <div class="col-md-2">
                                        <div class="form-text-row">
                                            @Html.DisplayFor(model => model.OrderSubTotalDiscountInclTax) <strong>@T("Admin.Orders.Fields.OrderSubTotalDiscountInclTax")</strong>
                                        </div>
                                    </div>
                                }
                                @if ((Model.AllowCustomersToSelectTaxDisplayType || Model.TaxDisplayType == TaxDisplayType.ExcludingTax) && !String.IsNullOrEmpty(Model.OrderSubTotalDiscountExclTax))
                                {
                                    <div class="col-md-10">
                                        <div class="form-text-row">
                                            @Html.DisplayFor(model => model.OrderSubTotalDiscountExclTax) <strong>@T("Admin.Orders.Fields.OrderSubTotalDiscountExclTax")</strong>
                                        </div>
                                    </div>
                                }
                            </div>
                        </div>
                    </div>
                }
                <div class="form-group">
                    <div class="col-md-3">
                        <div class="label-wrapper">
                            <label class="control-label">@T("Admin.Orders.Fields.OrderShipping")</label>
                            <div class="ico-help" title="@T("Admin.Orders.Fields.OrderShipping.Hint")">
                                <i class="fa fa-question-circle"></i>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-7">
                        <div class="row">
                            @if (Model.AllowCustomersToSelectTaxDisplayType || Model.TaxDisplayType == TaxDisplayType.IncludingTax)
                            {
                                <div class="col-md-2">
                                    <div class="form-text-row">
                                        @Html.DisplayFor(model => model.OrderShippingInclTax) <strong>@T("Admin.Orders.Fields.OrderShippingInclTax")</strong>
                                    </div>
                                </div>
                            }
                            @if (Model.AllowCustomersToSelectTaxDisplayType || Model.TaxDisplayType == TaxDisplayType.ExcludingTax)
                            {
                                <div class="col-md-2">
                                    <div class="form-text-row">
                                        @Html.DisplayFor(model => model.OrderShippingExclTax) <strong>@T("Admin.Orders.Fields.OrderShippingExclTax")</strong>
                                    </div>
                                </div>
                            }
                        </div>
                    </div>
                </div>
                if (((Model.AllowCustomersToSelectTaxDisplayType || Model.TaxDisplayType == TaxDisplayType.IncludingTax) && !String.IsNullOrEmpty(Model.PaymentMethodAdditionalFeeInclTax)) ||
                    ((Model.AllowCustomersToSelectTaxDisplayType || Model.TaxDisplayType == TaxDisplayType.ExcludingTax) && !String.IsNullOrEmpty(Model.PaymentMethodAdditionalFeeExclTax)))
                {
                    <div class="form-group">
                        <div class="col-md-3">
                            <div class="label-wrapper">
                                <label class="control-label">@T("Admin.Orders.Fields.PaymentMethodAdditionalFee")</label>
                                <div class="ico-help" title="@T("Admin.Orders.Fields.PaymentMethodAdditionalFee.Hint")">
                                    <i class="fa fa-question-circle"></i>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-7">
                            <div class="row">
                                @if (Model.AllowCustomersToSelectTaxDisplayType || Model.TaxDisplayType == TaxDisplayType.IncludingTax)
                                {
                                    <div class="col-md-2">
                                        <div class="form-text-row">
                                            @Html.DisplayFor(model => model.PaymentMethodAdditionalFeeInclTax) <strong>@T("Admin.Orders.Fields.PaymentMethodAdditionalFeeInclTax")</strong>
                                        </div>
                                    </div>
                                }
                                @if (Model.AllowCustomersToSelectTaxDisplayType || Model.TaxDisplayType == TaxDisplayType.ExcludingTax)
                                {
                                    <div class="col-md-2">
                                        <div class="form-text-row">
                                            @Html.DisplayFor(model => model.PaymentMethodAdditionalFeeExclTax) <strong>@T("Admin.Orders.Fields.PaymentMethodAdditionalFeeExclTax")</strong>
                                        </div>
                                    </div>
                                }
                            </div>
                        </div>
                    </div>
                }

                if (Model.DisplayTaxRates)
                {
                    foreach (var tr in Model.TaxRates)
                    {
                        <div class="form-group">
                            <div class="col-md-3">
                                @Html.SDFLabelFor(model => model.Tax) <span style="padding-top: 7px;margin-right: 5px;float: right;">@tr.Rate%</span>
                            </div>
                            <div class="col-md-9">
                                @tr.Value
                            </div>
                        </div>
                    }
                }
                if (Model.DisplayTax)
                {
                    <div class="form-group">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.Tax)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFDisplayFor(model => model.Tax)
                        </div>
                    </div>
                }
                if (!String.IsNullOrEmpty(Model.OrderTotalDiscount))
                {
                    <div class="form-group">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.OrderTotalDiscount)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFDisplayFor(model => model.OrderTotalDiscount)
                        </div>
                    </div>
                }
                foreach (var gc in Model.GiftCards)
                {
                    <div class="form-group">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.GiftCards[0].CouponCode)
                            <span style="padding-top: 7px;margin-right: 5px;float: right;">(@(gc.CouponCode))</span>
                        </div>
                        <div class="col-md-9">
                            @Html.SDFDisplay(gc.Amount)
                        </div>
                    </div>
                }
                if (Model.RedeemedRewardPoints > 0)
                {
                    <div class="form-group">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.RedeemedRewardPoints)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFDisplay(Model.RedeemedRewardPoints + @T("Admin.Orders.Fields.RedeemedRewardPoints.Points").Text + "/" + Model.RedeemedRewardPointsAmount)
                        </div>
                    </div>
                }
                <div class="form-group">
                    <div class="col-md-3">
                        @Html.SDFLabelFor(model => model.OrderTotal)
                    </div>
                    <div class="col-md-9">
                        @Html.SDFDisplayFor(model => model.OrderTotal)
                    </div>
                </div>
                if (!String.IsNullOrEmpty(Model.RefundedAmount))
                {
                    <div class="form-group">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.RefundedAmount)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFDisplayFor(model => model.RefundedAmount)
                        </div>
                    </div>
                }
                if (Model.UsedDiscounts.Count > 0)
                {
                    <div class="form-group">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.UsedDiscounts)
                        </div>
                        <div class="col-md-9">
                            @for (int i = 0; i < Model.UsedDiscounts.Count; i++)
                            {
                                var discount = Model.UsedDiscounts[i];
                                <a href="@Url.Action("Edit", "Discount", new {id = discount.DiscountId})">@discount.DiscountName</a>
                                if (i != Model.UsedDiscounts.Count - 1)
                                {
                                    <text>,</text>
                                }
                            }
                        </div>
                    </div>
                }
                <div class="form-group">
                    <div class="col-md-3">
                        @Html.SDFLabelFor(model => model.Profit)
                    </div>
                    <div class="col-md-9">
                        @Html.SDFDisplayFor(model => model.Profit)
                    </div>
                </div>

                <div id="trEditOrderTotals">
                    <div class="form-group">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.OrderSubtotalInclTaxValue)
                        </div>
                        <div class="col-md-9">
                            @T("Admin.Orders.Fields.Edit.InclTax")<span class="margin-r-10 margin-l-5">@Html.SDFEditorFor(model => model.OrderSubtotalInclTaxValue)</span>
                            @T("Admin.Orders.Fields.Edit.ExclTax")<span class="margin-l-5">@Html.SDFEditorFor(model => model.OrderSubtotalExclTaxValue)</span>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.OrderSubTotalDiscountInclTaxValue)
                        </div>
                        <div class="col-md-9">
                            @T("Admin.Orders.Fields.Edit.InclTax")<span class="margin-r-10 margin-l-5">@Html.SDFEditorFor(model => model.OrderSubTotalDiscountInclTaxValue)</span>
                            @T("Admin.Orders.Fields.Edit.ExclTax")<span class="margin-l-5">@Html.SDFEditorFor(model => model.OrderSubTotalDiscountExclTaxValue)</span>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.OrderShippingInclTaxValue)
                        </div>
                        <div class="col-md-9">
                            @T("Admin.Orders.Fields.Edit.InclTax")<span class="margin-r-10 margin-l-5">@Html.SDFEditorFor(model => model.OrderShippingInclTaxValue)</span>
                            @T("Admin.Orders.Fields.Edit.ExclTax")<span class="margin-l-5">@Html.SDFEditorFor(model => model.OrderShippingExclTaxValue)</span>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.PaymentMethodAdditionalFeeInclTaxValue)
                        </div>
                        <div class="col-md-9">
                            @T("Admin.Orders.Fields.Edit.InclTax")<span class="margin-r-10 margin-l-5">@Html.SDFEditorFor(model => model.PaymentMethodAdditionalFeeInclTaxValue)</span>
                            @T("Admin.Orders.Fields.Edit.ExclTax")<span class="margin-l-5">@Html.SDFEditorFor(model => model.PaymentMethodAdditionalFeeExclTaxValue)</span>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.TaxRatesValue)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.TaxRatesValue)
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.TaxValue)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.TaxValue)
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.OrderTotalDiscountValue)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.OrderTotalDiscountValue)
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.OrderTotalValue)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.OrderTotalValue)
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-md-9 col-md-offset-3">
                        <button type="submit" name="btnEditOrderTotals" onclick="toggleOrderTotals(true);return false;" id="btnEditOrderTotals" class="btn btn-primary">
                            @T("Admin.Orders.Fields.EditOrderTotals")
                        </button>

                        <button type="submit" name="btnSaveOrderTotals" id="btnSaveOrderTotals" class="btn btn-primary">
                            @T("Admin.Orders.Fields.SaveOrderTotals")
                        </button>
                        @Html.ActionConfirmation("btnSaveOrderTotals")

                        <button type="submit" name="btnCancelOrderTotals" onclick="toggleOrderTotals(false);return false;" id="btnCancelOrderTotals" class="btn bg-teal">
                            @T("Admin.Orders.Fields.CancelOrderTotals")
                        </button>
                    </div>
                </div>

                if (Model.AllowStoringCreditCardNumber)
                {
                    <div class="form-group">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.CardType)
                        </div>
                        <div class="col-md-9">
                            <div id="lblCardType">
                                @Html.SDFDisplayFor(model => model.CardType)
                            </div>
                            @Html.SDFEditorFor(model => model.CardType)
                        </div>
                    </div>
                }
                if (Model.AllowStoringCreditCardNumber)
                {
                    <div class="form-group">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.CardName)
                        </div>
                        <div class="col-md-9">
                            <div id="lblCardName">
                                @Html.SDFDisplayFor(model => model.CardName)
                            </div>
                            @Html.SDFEditorFor(model => model.CardName)
                        </div>
                    </div>
                }
                if (Model.AllowStoringCreditCardNumber || !String.IsNullOrEmpty(Model.CardNumber))
                {
                    <div class="form-group">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.CardNumber)
                        </div>
                        <div class="col-md-9">
                            <div id="lblCardNumber">
                                @Html.SDFDisplayFor(model => model.CardNumber)
                            </div>
                            @Html.SDFEditorFor(model => model.CardNumber)
                        </div>
                    </div>
                }
                if (Model.AllowStoringCreditCardNumber)
                {
                    <div class="form-group">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.CardCvv2)
                        </div>
                        <div class="col-md-9">
                            <div id="lblCardCvv2">
                                @Html.SDFDisplayFor(model => model.CardCvv2)
                            </div>
                            @Html.SDFEditorFor(model => model.CardCvv2)
                        </div>
                    </div>
                }
                if (Model.AllowStoringCreditCardNumber)
                {
                    <div class="form-group">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.CardExpirationMonth)
                        </div>
                        <div class="col-md-9">
                            <div id="lblCardExpirationMonth">
                                @Html.SDFDisplayFor(model => model.CardExpirationMonth)
                            </div>
                            @Html.SDFEditorFor(model => model.CardExpirationMonth)
                        </div>
                    </div>
                }
                if (Model.AllowStoringCreditCardNumber)
                {
                    <div class="form-group">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.CardExpirationYear)
                        </div>
                        <div class="col-md-9">
                            <div id="lblCardExpirationYear">
                                @Html.SDFDisplayFor(model => model.CardExpirationYear)
                            </div>
                            @Html.SDFEditorFor(model => model.CardExpirationYear)
                        </div>
                    </div>
                }
                if (Model.AllowStoringCreditCardNumber)
                {
                    <div class="form-group">
                        <div class="col-md-9 col-md-offset-3">
                            <button type="submit" name="btnEditCC" onclick="toggleCC(true);return false;" id="btnEditCC" class="btn btn-primary">
                                @T("Admin.Orders.Fields.EditCC")
                            </button>

                            <button type="submit" name="btnSaveCC" id="btnSaveCC" class="btn btn-primary">
                                @T("Admin.Orders.Fields.SaveCC")
                            </button>
                            @Html.ActionConfirmation("btnSaveCC")

                            <button type="submit" name="btnCancelCC" onclick="toggleCC(false);return false;" id="btnCancelCC" class="btn bg-teal">
                                @T("Admin.Orders.Fields.CancelCC")
                            </button>
                        </div>
                    </div>
                }
                if (!String.IsNullOrEmpty(Model.AuthorizationTransactionId))
                {
                    <div class="form-group">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.AuthorizationTransactionId)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFDisplayFor(model => model.AuthorizationTransactionId)
                        </div>
                    </div>
                }
                if (!String.IsNullOrEmpty(Model.CaptureTransactionId))
                {
                    <div class="form-group">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.CaptureTransactionId)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFDisplayFor(model => model.CaptureTransactionId)
                        </div>
                    </div>
                }
                if (!String.IsNullOrEmpty(Model.SubscriptionTransactionId))
                {
                    <div class="form-group">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.SubscriptionTransactionId)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFDisplayFor(model => model.SubscriptionTransactionId)
                        </div>
                    </div>
                }
                <div class="form-group">
                    <div class="col-md-3">
                        @Html.SDFLabelFor(model => model.PaymentMethod)
                    </div>
                    <div class="col-md-9">
                        @Html.SDFDisplayFor(model => model.PaymentMethod)
                    </div>
                </div>
            }
        </div>
    </div>

    <div class="panel panel-default">
        <div class="panel-body">
            <div class="form-group">
                <div class="col-md-3">
                    @Html.SDFLabelFor(model => model.PaymentStatus)
                </div>
                <div class="col-md-9">
                    @Html.SDFDisplayFor(model => model.PaymentStatus)
                </div>
            </div>
            @if (Model.CanCapture || Model.CanMarkOrderAsPaid || Model.CanRefund || Model.CanRefundOffline ||
                Model.CanPartiallyRefund || Model.CanPartiallyRefundOffline || Model.CanVoid || Model.CanVoidOffline)
            {
                <div class="form-group">
                    <div class="col-md-9 col-md-offset-3">
                        @if (!Model.IsLoggedInAsVendor)
                        {
                            if (Model.CanCapture)
                            {
                                <button type="submit" name="captureorder" id="captureorder" class="btn btn-primary">
                                    @T("Admin.Orders.Fields.Capture")
                                </button>
                                <text>&nbsp;</text>
                                @Html.ActionConfirmation("captureorder")
                            }
                            if (Model.CanMarkOrderAsPaid)
                            {
                                <button type="submit" name="markorderaspaid" id="markorderaspaid" class="btn btn-primary">
                                    @T("Admin.Orders.Fields.MarkAsPaid")
                                </button>
                                <text>&nbsp;</text>
                                @Html.ActionConfirmation("markorderaspaid")
                            }
                            if (Model.CanRefund)
                            {
                                <button type="submit" name="refundorder" id="refundorder" class="btn btn-primary">
                                    @T("Admin.Orders.Fields.Refund")
                                </button>
                                <text>&nbsp;</text>
                                @Html.ActionConfirmation("refundorder")
                            }
                            if (Model.CanRefundOffline)
                            {
                                <button type="submit" name="refundorderoffline" id="refundorderoffline" class="btn btn-primary">
                                    @T("Admin.Orders.Fields.RefundOffline")
                                </button>
                                <text>&nbsp;</text>
                                @Html.ActionConfirmation("refundorderoffline")
                            }
                            if (Model.CanPartiallyRefund)
                            {
                                <button type="submit" id="partiallyrefundorder" name="partiallyrefundorder" onclick="javascript:OpenWindow('@(Url.Action("PartiallyRefundOrderPopup", "Order", new {id = Model.Id, online = true, btnId = "btnRefreshPage", formId = "order-form"}))', 500, 300, true); return false;" class="btn btn-primary">
                                    @T("Admin.Orders.Fields.PartialRefund")
                                </button>
                                <text>&nbsp;</text>
                            }
                            if (Model.CanPartiallyRefundOffline)
                            {
                                <button type="submit" id="partiallyrefundorderoffline" name="partiallyrefundorderoffline" onclick="javascript:OpenWindow('@(Url.Action("PartiallyRefundOrderPopup", "Order", new {id = Model.Id, online = false, btnId = "btnRefreshPage", formId = "order-form"}))', 500, 300, true); return false;" class="btn btn-primary">
                                    @T("Admin.Orders.Fields.PartialRefundOffline")
                                </button>
                                <text>&nbsp;</text>
                            }
                            if (Model.CanVoid)
                            {
                                <button type="submit" name="voidorder" id="voidorder" class="btn btn-primary">
                                    @T("Admin.Orders.Fields.Void")
                                </button>
                                <text>&nbsp;</text>
                                @Html.ActionConfirmation("voidorder")
                            }
                            if (Model.CanVoidOffline)
                            {
                                <button type="submit" name="voidorderoffline" id="voidorderoffline" class="btn btn-primary">
                                    @T("Admin.Orders.Fields.VoidOffline")
                                </button>
                                <text>&nbsp;</text>
                                @Html.ActionConfirmation("voidorderoffline")
                            }
                        }
                    </div>
                </div>
            }
            @if (Model.CustomValues != null && Model.CustomValues.Count > 0)
            {
                <div class="form-group">
                    <div class="col-md-3">
                        @Html.SDFLabelFor(model => model.CustomValues)
                    </div>
                    <div class="col-md-9">
                        <div class="form-text-row">
                            @foreach (var item in Model.CustomValues)
                            {
                                <ul class="common-list">
                                    <li>
                                        @item.Key: @(item.Value != null ? item.Value.ToString() : "")
                                    </li>
                                </ul>
                            }
                        </div>
                    </div>
                </div>
            }
            <div class="form-group">
                <div class="col-md-3">
                    @Html.SDFLabelFor(model => model.CreatedOn)
                </div>
                <div class="col-md-9">
                    @Html.SDFDisplayFor(model => model.CreatedOn)
                </div>
            </div>
        </div>
    </div>
</div>